'''
产品首页
 '''
from selenium.webdriver.common.by import By
from page.base_page import BasePage

class ChanpingpShouye(BasePage):
    url = 'http://192.168.1.25/crm/index.php?m=product'

    # 点击产品
    dianji_locator = (By.CSS_SELECTOR,
                      'body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > div.nav-collapse.collapse > ul:nth-child(1) > li:nth-child(4) > a')
    # 添加产品
    tianjia_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div:nth-child(2) > div.pull-right > a')
    # 产品工具定位器
    cpgj_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div:nth-child(2) > div.pull-right > div > button')
    # 导入产品
    drcp_locator = (By.CSS_SELECTOR,'#import_excel')
    # 取消导入
    qxdr_locator = (
    By.CSS_SELECTOR, '#dialog-import > form > table > tbody > tr:nth-child(4) > td:nth-child(2) > input:nth-child(2)')
    # 导出产品
    dccp_locator = (By.CSS_SELECTOR, '#excelExport')
    # 勾选
    gx_locator = (By.CSS_SELECTOR,'#form1 > table > tbody > tr:nth-child(1) > td:nth-child(1) > input')
    # 删除
    sc_locator = (By.CSS_SELECTOR,'#delete')
    # 输入搜索产品
    shuruss_locator = (By.CSS_SELECTOR, '#search')
    # 点击搜索
    dianjiss_locator = (By.CSS_SELECTOR, '#dosearch')

    # 操作方法
    def dianjichanping(self):
        self.driver.find_element(*self.dianji_locator).click()

    def tianjiachanping(self):
        self.driver.find_element(*self.tianjia_locator).click()

    def chanpingdaoru(self):
        self.driver.find_element(*self.cpgj_locator).click()

    def daoruchanpin(self):
        self.driver.find_element(*self.drcp_locator).click()

    def quxioadaoru(self):
        self.driver.find_element(*self.qxdr_locator).click()

    def chanpingdaochu(self):
        self.driver.find_element(*self.dccp_locator).click()

    def gxcp(self):
        self.driver.find_element(*self.gx_locator).click()

    def sccp(self):
        self.driver.find_element(*self.sc_locator).click()

    def sousuochanpin(self,kunkun):
        self.driver.find_element(*self.shuruss_locator).send_keys(kunkun)

    def dianjisousuo(self):
        self.driver.find_element(*self.dianjiss_locator).click()

    # 弹框点击确定
    def queding(self):
        self.driver.switch_to.alert.accept()

    # 点击取消按钮
    def quxioa(self):
        self.driver.switch_to.alert.dismiss()

    # 获取页面url
    def get_url(self):
        url = self.driver.current_url
        return url
